home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / assignme.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.0 KB  |  48 lines

  1. /*
  2.                              A S S I G N M E . C
  3. */
  4.  
  5. #include "iccomp.h"
  6.  
  7. ESTRUC_ *assignment(lval, rval, opstr)      /* opstr is '=', or "/=", etc. */
  8.     ESTRUC_
  9.         *lval,
  10.         *rval;
  11.     char
  12.         *opstr;
  13. {
  14.     ESTRUC_
  15.         *tmp;
  16.     unsigned
  17.         type,
  18.         value;
  19.  
  20.     if (!test_type(lval, e_var))
  21.     {
  22.         semantic(lvalue_needed, opstr);
  23.         discard(rval);
  24.         return (lval);
  25.     }
  26.  
  27.     etoc(rval);                             /* convert rval to code */
  28.  
  29.                                             /* same types */
  30.     if (lval->type & rval->type & (e_int | e_str | e_list))
  31.     {
  32.         type = lval->type;                  /* save type/index for return */
  33.         value = lval->evalue;
  34.  
  35.         gencode(lval, op_copy_var, lval->evalue);
  36.         tmp = catcode(rval, lval);          /* catenate assignment code */
  37.  
  38.         tmp->evalue = value;                /* set lvalue type and index */
  39.         tmp->type = type;
  40.  
  41.         return (tmp);
  42.     }
  43.  
  44.     semantic(type_conflict, opstr);
  45.     discard(rval);
  46.     return (lval);
  47. }
  48.